package com.atguigu.springcloud.client;

import com.atguigu.springcloud.domain.Dept;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;
import java.util.List;
import java.util.Map;

@FeignClient(name = "MICROSERVICECLOUD-DEPT")
public interface ProviderClient1 {

    // 服务端GET请求，没有入参
    @RequestMapping(value = "/dept/list",method = RequestMethod.GET)
    List<Dept> list();

    // 服务端使用GET请求，且入参是从路径上取值
    @RequestMapping(value = "/dept/get/{id}",method = RequestMethod.GET)
    Dept get(@PathVariable("id") long id);

    // 服务端GET请求，只有一个String类型的入参
    @RequestMapping(value = "/dept/getById",method = RequestMethod.GET)
    Dept getById(@RequestParam(value = "id") Long id);

    // 服务端使用GET请求，且入参是一个实体类
    @RequestMapping(value = "/dept/getByDept",method = RequestMethod.GET)
    Dept getByDept(@RequestParam Map param);

    // 服务端GET请求，有一个以上的String类型入参
    @RequestMapping(value = "/dept/getByIdAndDeptName",method = RequestMethod.GET)
    Dept getByIdAndDeptName(@RequestParam(value = "id") Long id,
                            @RequestParam(value = "deptName") String deptName);

    // 服务器使用POST请求，入参是一个实体类
    @RequestMapping(value = "/dept/add",method = RequestMethod.POST)
    boolean add(@RequestBody Dept dept);

    // 服务器使用POST请求，入参是两个实体类
    @RequestMapping(value = "/dept/addWithAddress1", method = RequestMethod.POST)
    boolean addWithAddress1(@RequestParam(value = "username") String username,
                           @RequestBody Dept dept);
}
